package org.je.thread;

import org.je.log.JLog;
import org.je.util.WrappedBlockingQueue;

/**
 * @author fanyifeng
 */
public class TaskWorker extends Thread
{
	private WrappedBlockingQueue<Task>	taskQueue;

	public TaskWorker(WrappedBlockingQueue<Task> queue) {
		taskQueue = queue;
	}

	public void run() {
		while( true ) {
			Task task = taskQueue.take();
			if (task == Task.CLOSE_THREAD) {
				break;
			}
			try {
				task.execute();
			} catch (Throwable ex) {
				JLog.info(ex);
			} 
		}
	}
}
